Using Multiple Cameras in Shockwave 3D Worlds
Marty Plumbo
One World, Many Perspectives
A defining aspect of working with interactive 3D is that once you've created 3D worlds, users can then observed them from an infinite number of locations and perspectives. This is one of the biggest differences between traditional sprite-based animation and animation based on real-time 3D; the power of it is hard to overstate. Let's say for example that you want to create an interactive 3D animation that demonstrates how a jet engine works. You've decided to show air as it flows through the various parts of the engine. To do this in 2D, you will need to create sprite graphics that represent not only every animated element, but each will have to be created as viewed from the various angles that it is to be show. In 3D, on the other hand, you only need to create one animated 3D model of the jet entire engine and then simply provide the user with a means of changing the position and orientation as they view it.
Two Multiple Camera Techniques
In previous articles, you may have seen how you can view objects in a real-time 3D world from various perspectives as you rotate and translate them in space and you saw how you could view the 3D world from different perspectives and locations by moving the virtual camera from within the 3D world. In this article, I review two common approaches to using multiple static cameras in a 3D world, using a simple real-time 3D jet engine demonstration like the one described above.
Requirements
To complete this tutorial you will need to install the following software and files:
Director
3DPI Xtra
Familiarity with the basics of Shockwave3D, 3D Lingo, and the 3DPI property inspector
Tutorials and sample files:
media.zip
(285K)
Shockwave 3D Camera Basics
Like all Director cast members, a Shockwave 3D cast member is for all intents and purposes invisible until a sprite of it is created on Director's Stage. When you create a sprite from a Shockwave 3D cast member, the image on the Stage is a View Port into the 3D world inside that cast member, as seen through one of its cameras. A Shockwave 3D cast member can have any number of cameras in it, but each sprite of that cast member can only use one of them at a time to depict that world on the Stage. Luckily, you can change the specific camera that a Shockwave 3D sprite uses because it is a property of that sprite. So, while a Shockwave 3D sprite can only look into its cast member's 3D world through one camera, you can easily change that camera.
The basic format for setting the camera that a Shockwave 3D sprite uses is as follows:
sprite(whichSprite).camera = member(whichMember).camera(whichCamera)
Now, let's put this information to work!
3D World Setup
This article assumes you are already familiar with the basics of Shockwave 3D, 3D Lingo, and the 3DPI property inspector.
Before you begin, download the sample files at the beginning of the article. These consists of two sample movies (sample1.dir and sample2.dir) and a single W3D file. The W3D file has been imported into both sample movies. I created this file in Alias|Wavefront Maya to depict a simple, animated, cut-away 3D jet engine. In creating it, I set up four cameras, each using a different view (see figure 1). As you may have already surmised, positioning and orienting cameras in a 3D scene is much easier in the visual environment of a 3D authoring program than in Director.
Figure 1. Setting up multiple cameras in the 3D modeling application
Load the sample1.dir file in Director. In this movie, four sprites of the Shockwave 3D cast member have been arranged on the stage, each viewing the 3D world through its default camera (see Figure 2).
Figure 2. The initial state of the sample1.dir movie
If you don't already have the “3DPI” Xtra installed, go to www.3dpi-director.com to download a free trial version of this indispensable Shockwave 3D cast member inspector before continuing. In 3DPI, view the Camera panel for the Shockwave 3D cast member, noting the names of each of the four custom cameras in the scene: cam_Shape1, cam_Shape2, cam_Shape3 and cam_Shape4 (see Figure 3).
Figure 3. Using 3DPI to get 3D world camera information
Simultaneously Using Multiple Camera Views
Often, it is useful in instructional media to show the changes across time occurring in a given process from more than one perspective, at the same time. Real-time 3D excels at demonstrating concepts in this way. The first multiple camera technique that I examine uses multiple sprites in the same 3D world to do just that.
As you recall, the 3D scene shows a single animated process but has cameras set up at several different locations, each trained on a part of that process. Initially, the four Shockwave 3D sprites of the jet engine scene in the sample1.dir movie all show the scene through its default camera (see Figure 2). When executed, the four Shockwave 3D sprites each look at the scene through a different camera (see Figure 4).
Figure 4. The sample1.dir movie in action
I accomplished this by using a single behavior attached to each sprite, which instructs it to use a specific camera, specified as a behavior parameter (see Figure 5).
Figure 5. Inspecting the camera-selecting behavior
The behavior accomplishes this by using a single line of code in its
beginSprite handler which sets the camera property of the
sprite to a specific camera name, based on the camera-setting code described
earlier. The remaining code in the behavior helps specify the camera
that the sprite will use, through a behavior property:
property pCamera on beginSprite me -- set this sprite's camera to the -- one selected sprite(me.spriteNum).camera = sprite(me.spriteNum).member.camera(pCamera) end on getPropertyDescriptionList me propList = [:] -- let the author specify which -- camera to use by name addProp propList, #pCamera, [#comment:"Camera name: ", #format:#string, #default:""] return propList end
Switching Between Multiple Camera Views
Another useful approach in instructional media lets the user select and view a time-based process from different perspectives. A typical example is to have a single View Port into a 3D world, which you can switch to use different cameras by clicking a series buttons; this is exactly what happens in the sample2.dir movie (see Figure 6).
Figure 6. The sample2.dir movie in action
As before, this movie accomplishes this through a single behavior,
only this time, in the movie, I attached the behavior to each of the
four buttons that a user clicks, which changes the camera
property of the single Shockwave 3D sprite through two behavior parameters
(see Figure 7).
Figure 7. Inspecting the camera-button behavior
This behavior is a slightly-modified version of the previous one. Its modifications consist of no new 3D Lingo, but rather just a single new behavior property, which it uses to facilitate specification of the sprite channel number of button's target Shockwave 3D sprite:
property pSprite, pCamera on mouseUp me -- set this sprite's camera to -- the one selected sprite(pSprite).camera = sprite(pSprite).member.camera(pCamera) end on getPropertyDescriptionList me propList = [:] -- let the author specify -- which sprite to use by -- channel number addProp propList, #pSprite, [#comment:"Sprite to effect: ", #format: #integer, #default: 1] -- let the author specify which -- camera to use by name addProp propList, #pCamera, [#comment:"Camera to use: ", #format: #string, #default: ""] return propList end
Conclusion
By now you should have an idea of some of the powerful possibilities of using multiple cameras in real-time 3D. The ability to create a complex animated or interactive scene once, and then view it from various or changing perspectives in real-time, opens the door to expressions of visual information in entirely new spatial and temporal combinations.